package com.hyou.springboot.annotation.validator;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import com.hyou.springboot.validator.constraints.URLValidator;

/**
 * 校验URL或URL片段
 * 
 * @author FengChangshuo
 * @version 1.0.0 2018-11-15 16:52:15 初始创建
 */
@Documented
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR,
        ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = URLValidator.class)
public @interface URL {
    
    String message() default "URL格式错误";
    
    Class<?>[] groups() default {};
    
    Class<? extends Payload>[] payload() default {};
    
    /**
     * Defines several {@code @URL } annotations on the same element.
     */
    @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR,
            ElementType.PARAMETER })
    @Retention(RUNTIME)
    @Documented
    public @interface List {
        URL[] value();
    }
    
}
